﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.ExtraInformation;
using Microsoft.Practices.EnterpriseLibrary.Logging.Filters;

namespace MonolithHelper
{
    public class Logger
    {
        public static void Write(string message,string title,MyConsoleMode mode = MyConsoleMode.WriteLineRegular)
        {
            LogEntry logEntry = new LogEntry();

            logEntry.EventId = 600;
            logEntry.Priority = 2;
            logEntry.Title = title;
            logEntry.Message = message;
            logEntry.Categories.Add("General");
            //logEntry.Categories.Add("UI Events");
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEntry);

            switch (mode)
            {
                case MyConsoleMode.WriteLineRegular:
                    MyConsole.WriteLineRegular(message);
                    break;
                case MyConsoleMode.WriteLineStart:
                    MyConsole.WriteLineStart(message);
                    break;

                case MyConsoleMode.WriteLineEnd:
                    MyConsole.WriteLineEnd(message);
                    break;

                default:
                    MyConsole.WriteLineRegular(message);
                    break;

            }

            Console.WriteLine(DateTime.Now.ToShortTimeString() + "    " + message);
        }

        public static void WriteError(string message,string title)
        {
            LogEntry logEntry = new LogEntry();

            logEntry.EventId = 601;
            logEntry.Priority = 3;
            logEntry.Severity = System.Diagnostics.TraceEventType.Error;
            logEntry.Title = title;
            logEntry.Message = message;
            logEntry.Categories.Add("Logging Errors & Warnings");
            //logEntry.Categories.Add("UI Events");
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEntry);
            MyConsole.WriteLineError(message);
        }
    }
}
